package Test0102;

public class Platform {
    String name;
    Order[] arr = new Order[3];
    int i = 0;

    public Platform() {
    }

    public Platform(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "Platform{" +
                "name='" + name + '\'' +
                '}';
    }
    public void add(Order order){
        arr[i]=order;
        i++;
    }
    public void printAll(){
        for (Order a:arr){
            System.out.println(a);
        }
    }
    public Order findMaxOrder(){
        Order maxOrder = arr[0];
        for (Order b:arr){
            if (b.getSalary()> maxOrder.getSalary()){
                maxOrder = b;
            }
        }
        return maxOrder;
    }
    public Order findMinOrder(){
        Order minOrder = arr[0];
        for (Order c:arr){
            if (c.getSalary()<minOrder.getSalary()){
                minOrder = c;
            }
        }
        return minOrder;
    }
    public Order findOrderByName(String Bob){
        Order specificOrder = null;
        for (Order d:arr){
            if (d.getName()==Bob){
                specificOrder = d;
            }
        }
        return specificOrder;
    }
    public double calculateAverage(){
        double sum = 0;
        for (Order e:arr){
            sum+=e.getSalary();
        }
        return sum/arr.length;
    }
}